<?php

namespace Common\Bundle\LibraryBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Doctrine\ORM\Mapping as ORM;

/**
 * Theme
 *
 * @ORM\Table("theme")
 * @ORM\Entity(repositoryClass="Common\Bundle\LibraryBundle\Entity\Repository\ThemeRepository")
 * @UniqueEntity(fields={"nom","theme"}, message="Un thème ayant le même intitulé existe déjà.")
 */
class Theme
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="nom", type="string", length=255)
     * @Assert\NotBlank()
     */
    private $nom;

    /**
     * @var Theme
     *
     * @ORM\ManyToOne(targetEntity="\Common\Bundle\LibraryBundle\Entity\Theme", cascade={"persist"})
     */
    private $theme;

    /**
     * @var User
     *
     * @ORM\ManyToMany(targetEntity="\Common\Bundle\UserBundle\Entity\User", cascade={"persist"}, inversedBy="themes")
     */
    private $users;

    /**
     * @var integer
     *
     * @ORM\Column(name="ordre", type="integer", nullable=true)
     */
    private $ordre;

    /**
     * @var boolean
     *
     * @ORM\Column(name="actif", type="boolean")
     */
    private $actif;

    /**
     * @var Qcm
     *
     * @ORM\OneToMany(targetEntity="\Common\Bundle\LibraryBundle\Entity\Qcm", mappedBy="theme")
     */
    private $qcms;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nom
     *
     * @param string $nom
     * @return Theme
     */
    public function setNom($nom)
    {
        $this->nom = $nom;

        return $this;
    }

    /**
     * Get nom
     *
     * @return string 
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set parent
     *
     * @param integer $parent
     * @return Theme
     */
    public function setParent($parent)
    {
        $this->parent = $parent;

        return $this;
    }

    /**
     * Get parent
     *
     * @return integer 
     */
    public function getParent()
    {
        return $this->parent;
    }

    /**
     * Set ordre
     *
     * @param integer $ordre
     * @return Theme
     */
    public function setOrdre($ordre)
    {
        $this->ordre = $ordre;

        return $this;
    }

    /**
     * Get ordre
     *
     * @return integer 
     */
    public function getOrdre()
    {
        return $this->ordre;
    }

    /**
     * @param boolean $actif
     */
    public function setActif($actif)
    {
        $this->actif = $actif;
    }

    /**
     * @return boolean
     */
    public function getActif()
    {
        return $this->actif;
    }

    /**
     * @param \Common\Bundle\LibraryBundle\Entity\Theme $theme
     */
    public function setTheme($theme)
    {
        $this->theme = $theme;
    }

    /**
     * @return \Common\Bundle\LibraryBundle\Entity\Theme
     */
    public function getTheme()
    {
        return $this->theme;
    }

    /**
     * Add users
     *
     * @param \Common\Bundle\UserBundle\Entity\User $user
     * @return User
     */
    public function addUser(\Common\Bundle\UserBundle\Entity\User $users)
    {
        $this->users[] = $users;

        return $this;
    }

    /**
     * Remove users
     *
     * @param \Common\Bundle\UserBundle\Entity\User $users
     */
public function removeUser(\Common\Bundle\UserBundle\Entity\User $users)
    {
        $this->users->removeElement($users);
    }

    /**
     * @return \Common\Bundle\UserBundle\Entity\User
     */
    public function getUsers()
    {
        return $this->users;
    }

    public function __toString()
    {
        return $this->getNom();
    }


}
